Skip to content

Upload diagnostics, adaptive request size, and upload scheduling - #11

Merged
tetujin merged 2 commits into
mainfrom
feature/upload-diagnostics
Nov 25, 2026
Merged

tetujin merged 2 commits into
mainfrom
feature/upload-diagnostics

Conversation

@tetujin

@tetujin tetujin commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Upload diagnostics, adaptive request size and request prefetch

  • SyncDiagnostics records each request (prepare, connect, send, server, delete, rest, retry wait) from URLSessionTaskMetrics, summarizes each sync with its bottleneck, and posts Notification.Name.Aware.dbSyncDiagnostics.
  • SyncBatchLimit uses 4 MB by default for every server type (the PHP AWARE server is retired; Flask serves its endpoints). After 3 full, fast requests in a row the limit grows by half, up to maxBatchBytesCeiling (8 MB by default). A limit learned from a 413 grows back, but never above 90% of the smallest rejected size.
  • prefetchNextBatch builds the next request while the current one is in flight.
  • DbSyncConfig.default* static values let an app set the request size and pacing of every sensor at once.

Upload scheduling and encoding

  • UploadScheduler: decides when to upload (interval timer, the device starting to charge, background uploads through BGProcessingTask), and tracks Wi-Fi (NWPathMonitor) and charging state.
  • UploadJSONBytes / SQLiteEngine.appendUploadJSON: encode upload rows straight from the SQLite C API into JSON bytes, reusing repeated text values. Process-wide upload cancellation (stopAllSyncs), AWARE Hub request format, and batch metrics (batchHandler).
  • Tests for AWARE Hub, batching, JSON encoding of tricky values, SQLiteEngine saves and the scheduler.

Test plan

  • AwareClient (aware-client-ios-v3 feature/upload-diagnostics) builds with this branch and runs on an iPhone 15 Pro, with uploads and sensing working
  • Package test suite (not run as part of opening this PR)

🤖 Generated with Claude Code

tetujin and others added 2 commits November 24, 2026 00:36
- SyncDiagnostics: record each request (prepare, connect, send, server,
  delete, rest, retry wait) using URLSessionTaskMetrics, summarize each
  sync with its bottleneck, and post Notification.Name.Aware.dbSyncDiagnostics.
- SyncBatchLimit: 4 MB default for every server type (the PHP AWARE server
  is retired; Flask serves its endpoints). After 3 full and fast requests
  in a row the limit grows by half up to maxBatchBytesCeiling (8 MB by
  default), like AWAREFetchSizeAdjuster. A limit learned from 413 grows
  back, but never above 90% of the smallest rejected size.
- prefetchNextBatch: choose and build the next request while the current
  one is in flight.
- DbSyncConfig.default* static values let an app set the request size and
  pacing of every sensor at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tetujin
tetujin merged commit 786adaa into main Nov 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant